﻿//  --------------------------------
//  Copyright (c) AW Systems, Inc. All rights reserved.
//  This source code is made available under the terms of the Microsoft Public License (Ms-PL)
//  http://www.codeplex.com/SLAM/license
//  ---------------------------------

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Slam.Configuration;

namespace Slam.Configuration
{
    /// <summary>
    /// IConfigurationManager provides access to SLAM's configuration.
    /// </summary>
    /// <remarks>
    /// The SLAM configuration has one essential section, the DataMapping.  Other sections
    /// can be registered with a Configuration Manager and retrieved using GetSection.
    /// </remarks>
    public interface IConfigurationManager
    {
        /// <summary>
        /// The SLAM configuration's default DataMapping section.
        /// </summary>
        DataMapping DataMapping { get; }

        /// <summary>
        /// Collection of all DataMapping sections.
        /// </summary>
        Dictionary<string, DataMapping> DataMappings { get; }

        /// <summary>
        /// Returns a registered custom configuration section by name.
        /// </summary>
        /// <param name="sectionName">Name of the section as registered</param>
        /// <returns>Object representing a section as registered</returns>
        object GetSection(string sectionName);

        /// <summary>
        /// Returns a registered typed custom configuration section by name.
        /// </summary>
        /// <typeparam name="SECTIONTYPE">Type of section expected</typeparam>
        /// <param name="sectionName">Name of the section as registered</param>
        /// <returns>Strongly typed object representing a section</returns>
        SECTIONTYPE GetSection<SECTIONTYPE>(string sectionName);

        /// <summary>
        /// Registers a custom configuration section to be handled by the SLAM configuration
        /// manager.  Registered sections require a name for retrieval and a delegate to be invoked
        /// when GetSection is called.
        /// </summary>
        /// <param name="sectionName">Name of the section</param>
        /// <param name="getSection">Delegate function called when GetSection is called for the given sectionName</param>
        void RegisterSection(string sectionName, Func<object, object> getSection);
    }
}
